fix: non editable paragraphs insertion - #131
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request adjusts Android’s NonEditableParagraphFilter to avoid inserting duplicate newlines when text is inserted at the boundary of a non-editable paragraph span.
Changes:
- Added
prependNewlineIfMissing(...)to prepend a newline only when the inserted text doesn’t already start with one. - Updated two insertion paths to use
prependNewlineIfMissing(...)instead of unconditionally prefixing\n. - Added
SpannableStringBuilderusage to build the resulting inserted text while preserving span behavior.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
36
to
38
| if (spanEnd == dstart) { | ||
| return Strings.NEWLINE_STRING + source | ||
| return prependNewlineIfMissing(source, start, end) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This pull request improves how newlines are inserted before non-editable paragraph spans in the
NonEditableParagraphFilterclass. The main change is to ensure that a newline is only prepended if the inserted text does not already start with one, preventing duplicate newlines.Enhancements to newline handling:
prependNewlineIfMissingmethod to check if the inserted text already starts with a newline and only prepend one if necessary.prependNewlineIfMissinginstead of unconditionally prepending a newline, improving the user experience and preventing unwanted extra newlines.Imports:
SpannableStringBuilderto support the new method.Test Plan
Screenshots / Videos
Screen.Recording.2026-07-21.at.01.54.13.mov
Compatibility